﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MIS.Logistics.Website.Models
{
    /// <summary>
    /// 控制器和Action
    /// </summary>
    public class ControllerAction
    {
        public int Id
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// IsController是指是否是controller，如果为false，
        /// 表示是action，那么controllerName字段就派上用场了
        /// </summary>
        public bool IsController
        {
            get;
            set;
        }

        /// <summary>
        /// 控制器名称
        /// 如果IsController为false，该项不能为空
        /// </summary>
        public string ControllName
        {
            get;
            set;
        }

        /// <summary>
        /// 是指是否允许没有权限的人访问 
        /// </summary>
        public bool IsAllowedNoneRoles
        {
            get;
            set;
        }

        /// <summary>
        /// 是否允许有角色的人访问 
        /// </summary>
        public bool IsAllowedAllRoles
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 用户与角色的关联表
    /// </summary>
    public class ControllerActionRole
    {
        public int Id
        {
            get;
            set;
        }

        /// <summary>
        /// 对应的ControllerAction编号
        /// </summary>
        public int ControllerActioId
        {
            get;
            set;
        }

        /// <summary>
        /// 对应的角色编号
        /// </summary>
        public int RoleId
        {
            get;
            set;
        }

        /// <summary>
        /// IsAllowed表示包含RoleId的用户是否有权限访问ControllerActioId
        /// </summary>
        public bool IsAllowed
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 角色
    /// </summary>
    public class Role
    {
        public int Id
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Description
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 用户
    /// </summary>
    public class User
    {
        public int Id
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 用户与角色的关联表
    /// </summary>
    public class UserRole
    {
        public int Id
        {
            get;
            set;
        }
        public int UserId
        {
            get;
            set;
        }
        public int RoleId
        {
            get;
            set;
        }
    }
}
